<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>骡窝窝系统管理平台</title>
    <#include "../common/header.ftl"/>
</head>

<body>
<div class="container">
<#include "../common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
		<#assign currentMenu = "travel" />
        <#include "../common/menu.ftl" />
        </div>
        <div class="col-sm-9">
            <div class="page-header">
                <h3>待审核游记管理</h3>
            </div>
            <div class="row">
                <!-- 提交分页的表单 -->
                <form id="searchForm" class="form-inline" method="post" action="/travel/list.do">
                    <input type="hidden" name="currentPage" id="currentPage" value="1"/>

                    <div class="form-group">
                        <label>状态</label>
                        <select id="auditState" class="form-control"  name="state">
                            <option value="-2">全部</option>
                            <option value="1">待发布</option>
                            <option value="-1">已拒绝</option>
                        </select>
                        <button id="query" type="button" class="btn btn-success"><i class="icon-search"></i>查询</button>
                    </div>
                </form>
            </div>
            <script>
                $("#auditState").val("${(qo.state)!}");
            </script>
            <div class="row">
                <table class="table">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>标题</th>
                        <th>封面</th>
                        <th>地点</th>
                        <th>作者</th>
                        <th>状态</th>
                        <th></th>
                        <th></th>
                        <th></th>
                    </tr>

                    </thead>
                    <tbody>
					<#list pageInfo.list as entity>
                    <tr>
                        <td>${entity_index +  1}</td>
                        <td>${entity.title!""}</td>
                        <td><img src='${entity.coverUrl!"" }' width="30px"/></td>
                        <td>${entity.place.name!""}</td>
                        <td>${entity.author.nickName!""}</td>
                        <td>${entity.stateName!""}</td>
                        <td><a class="changeStateBtn"  data-did="${entity.id}" data-state="2">发布</a></td>
                        <td><a class="changeStateBtn"  data-did="${entity.id}" data-state="-1">拒绝</a></td>
                        <td><a class="seeArticle" role="button" data-did="${entity.id}">查看文章</a></td>
                    </tr>
					</#list>
                    </tbody>
                </table>
                <#include "../common/page.ftl"/>
            </div>
        </div>
    </div>
</div>
<div id="travelModal" class="modal" tabindex="-1" role="dialog" >
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title contentTitle"></h4>
            </div>
            <div class="modal-body content">
            </div>
            <div class="modal-footer">
                <a href="javascript:void(0);" class="btn" data-dismiss="modal" aria-hidden="true">关闭</a>
            </div>
        </div>
    </div>
</div>
<style>
    #travelModal img {
        width: 100%;
    }
</style>
<script>
    $("#query").click(function () {
        $("#searchForm").submit();
    });
    $(".changeStateBtn").click(function () {
        var state = $(this).data("state");
        var id = $(this).data("did");
        $.post("/travel/changeState.do",{"id":id,"state":state},function () {
            doSucceed();
        })
    });

    function doSucceed() {
        $.messager.alert("操作成功", "2秒后自动关闭");
        setTimeout(function () {
            location.reload();
        },1024);
    }
    $(".seeArticle").click(function () {
        $.get("/travel/getContent.do?id="+$(this).data("did"),function (data) {
            $("#travelModal .content").html(data.travelContent.content);
            $("#travelModal .contentTitle").html(data.title);
            $("#travelModal").modal("show");
        })

    });
</script>
</body>
</html>